#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef int ElemType;
typedef struct
{
    ElemType *elem;//整形指针
    int TableLen;//存储动态数组里元素的个数
}SSTable;
void ST_Init(SSTable &ST,ElemType len)
{
    ST.TableLen=len+1;
    ST.elem=(ElemType*) malloc(sizeof(ElemType)*ST.TableLen);
    int i;
    srand(time(NULL));
    for (int i = 1; i < ST.TableLen; i++) {
        ST.elem[i]=rand()%100;
    }
}
void ST_print(SSTable ST)
{
    for (int i = 1;i <ST.TableLen;i++) {
        printf("%3d",ST.elem[i]);
    }
    printf("\n");
}
int search_seq(SSTable ST,ElemType k)
{
    ST.elem[0]=k;
    int i;
    for (i=ST.TableLen-1;ST.elem[i]!=k;i--)
    {}
    return i;
}
int main()
{
    SSTable ST;
    ST_Init(ST,10);
    ST_print(ST);
    printf("please input need : \n");
    ElemType key;
    int pos;//存储查询元素的位置
    scanf("%d",&key);
    pos=search_seq(ST,key);
    if (pos)
    {
        printf("find key , pos = %d\n",pos);
    }
    else
    {
        printf("not find\n");
    }
    return 0;
}